<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['ischecklogin']=model('jy_weishop/member')->checklogin('','','','',true);
	$type=intval($_RQ['type']);
	$return['setting']=$this->plugin_setting('page_setting');
	$return['list']=array();
	$return['params']=array('type'=>$type);
	$type=intval($_RQ['type'])?:array(1,2,3,4,5);
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$lastdaytime = $daytime-24*3600;
	$data['allfee1']=0;
	$data['allfee2']=pdo_getsum('jy_newcar_yufee',array('status'=>array(1,2,3),'type'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'money');
	$data['allfee']=$data['allfee1']+$data['allfee2'];
	$data['lastfee1']=0;
	$data['lastfee2']=pdo_getsum('jy_newcar_yufee',array('status'=>1,'type'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'money');
	$data['lastfee']=$data['lastfee1']+$data['lastfee2'];
	$data['tuifee']=pdo_getsum('jy_newcar_commission',array('type'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'money');
	$data['allfee'] +=$data['tuifee'];
	$data['allfee']=price($data['allfee']);
	$member=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','credit3','credit4','credit5','credit6','mobile','avatar','nickname'));
	$return['member']=$member;
	$return['data']=$data;
	$return['setting']=$this->plugin_setting('page_setting');
	$return['setting']['balance_money']=$this->setting['balance_money'];
	$diytitle=array('tagent','tshop','tmyshop','tcenter','tbecome','balance_button','tcommission','tcommission1','commission_total','commission_1','balance_total','balance_1','commission_1_1','commission_0','balance_2','balance_3','balance_pay','tcommission_detail','torder','tdown','tmydown','area_title','commission_area');
	foreach($diytitle as $v){
		$return['setting'][$v]=$return['setting'][$v.'2']?:$return['setting'][$v];
	}
	set_html('title','推广组奖励明细');
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'type'=>1);
	if($_RQ['orderid']){
		$params['orderid']=$_RQ['orderid'];
	}
	$psize=20;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'orderby'=>'id desc',
	);
	$list=$this->get_list('tuilog',$parameter);
	if(!$list){
		exi('none');
	}
	$nowmonth=date('m');
	foreach($list as &$item){
		$item['istui']=pdo_count('jy_newcar_order',array('tuilogid'=>$item['id'],'uniacid'=>$_SESSION['uniacid']));
		$item['statustitle']=$this->tuilog_status[$item['status']];
		for($i=0;$i<36;$i++){
			$yueend = mktime(0,0,0,$nowmonth+$i+1,1,date('Y'));
			if($yueend>=$item['endtime']){
				$lastqi=$i;
				break;
			}
		}
		$item['lastqi']=$lastqi;
		$item['createtime']=date('Y-m-d H:i',$item['createtime']);
		$item['endtime']=$item['endtime']?date('Y-m-d H:i',$item['endtime']):'';
	}
	exi($list);
}
?>